﻿using System;
using System.Collections.Generic;
using System.Drawing;
using BobcatUtility;
using System.Runtime.Serialization;

namespace CNShapes
{
    /// <summary>
    /// A base class for shapes that have rectangular bounds as their defining
    /// properties. This includes boxes, ellipses and arrows for example.
    /// </summary>
    [DataContract]
    public abstract class ShapeBase_RectangularBounds : ShapeBase_DrawnWithPen
    {
        #region Public properties

        /// <summary>
        /// Property to get or set the start point.
        /// </summary>
        public PointF StartPoint
        {
            get
            {
                return m_StartPoint;
            }
            set
            {
                // When you set the start point, we set both the start and end points as the same.
                // Otherwise the end point will be at (0, 0) and rendering will look weird.
                m_StartPoint = Utility.copy(value);
                m_EndPoint = Utility.copy(value);
                updateBounds(m_StartPoint, m_EndPoint);
                raiseShapeEditedEvent();
            }
        }

        /// <summary>
        /// Property to get or set the end point of the shape.
        /// </summary>
        public PointF EndPoint
        {
            get
            {
                return m_EndPoint;
            }
            set
            {
                m_EndPoint = Utility.copy(value);
                updateBounds(m_StartPoint, m_EndPoint);
                raiseShapeEditedEvent();
            }
        }

        #endregion

        #region Protected data

        // The start and end point of the arrow.
        [DataMember]
        protected PointF m_StartPoint = new PointF();
        [DataMember]
        protected PointF m_EndPoint = new PointF();

        #endregion
    }
}
